package com.lsh.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lsh.dao.DiscussPostMapper;
import com.lsh.pojo.DiscussPost;
import com.lsh.service.IDiscussPostService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 刘书豪
 * @since 2022-07-22
 */
@Service
public class DiscussPostServiceImpl extends ServiceImpl<DiscussPostMapper, DiscussPost> implements IDiscussPostService {
    @Resource
    private DiscussPostMapper discussPostMapper;

    @Override
    public List<DiscussPost> list() {
        return super.list();
    }
    @Override
    public List<DiscussPost> selectPage(int current,int size) {
        QueryWrapper<DiscussPost> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("type");
        Page<DiscussPost> page = new Page<>(current, size);
        Page<DiscussPost> discussPostPage = discussPostMapper.selectPage(page,wrapper);
        return discussPostPage.getRecords();
    }

    @Override
    public long getTotal() {
        Page<DiscussPost> page = new Page<>(1, 10);
        Page<DiscussPost> discussPostPage = discussPostMapper.selectPage(page, null);
        return discussPostPage.getTotal();
    }

}
